Get a dictionary from an object’s fields

Get a dictionary from an object’s fields.
class dictObj(object):

     def __init__(self):
         self.x = 'red'
         self.y = 'Yellow'
         self.z = 'Green'

     def do_nothing(self):
         pass

DO = dictObj()
print(DO.__dict__)    # {'y': 'Yellow', 'z': 'Green', 'x': 'red'}